package com.admin.library.controller;

import com.admin.library.common.base.BaseController;
import com.admin.library.common.base.R;
import com.admin.library.domain.entity.BookClass;
import com.admin.library.service.BookClassService;
import com.admin.library.service.BookService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Lii
 * @create 2022-05-27 20:57
 */

@RestController
@RequestMapping("/bookClass")
public class BookClassController extends BaseController {

    @Resource
    private BookClassService bookClassService;

    @GetMapping("/list")
    public R selectAll(Page<BookClass> page, BookClass bookClass) {
        return result(this.bookClassService.page(page, bookClass));
    }

    @PostMapping("/add")
    public R addBookClass(@RequestBody BookClass bookClass) {
        return result(bookClassService.save(bookClass));
    }


    @PostMapping("/update")
    public R updateBookClass(@RequestBody BookClass bookClass) {
        return result(bookClassService.updateById(bookClass));
    }

    @GetMapping("/delete")
    public R deleteBookClass(@RequestParam List<String> ids) {
        return result(bookClassService.removeByIds(ids));
    }

}
